<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>列表</title>
    <link rel="stylesheet" href="../../css/aui.css">
    <link rel="stylesheet" href="../../css/swiper.min.css">
    <link rel="stylesheet" href="../../css/common.css">
    <link rel="stylesheet" href="../../css/iconfont/iconfont.css">

    <script type="text/javascript" src="../../script/api.js"></script>
    <script language="JavaScript" src="../../script/vue.js"></script>
    <script language="javascript" src="../../script/swiper.min.js"></script>
    <script language="JavaScript" src="../../script/common.js"></script>

</head>

<body>
    <div id="products-box" v-cloak>

        <div class="swiper-container aui-content" style="border-top:2px solid #e5e5e5;background-color: #fff" v-if="typelogo.length>0">
            <section class="aui-grid    ">
                <div class="aui-row  ">
                    <div class="aui-col-5" @click="opensearch(item)" v-for="(item,index) in typelogo" style="padding: 0.2rem 0;">

      <img onload="fnLoadImage(this)" class="icon-img" :data-url="item.logo_url" src="../../image/default.png"  width="43" height="43"/>

                        <div class="aui-grid-label">{{item.title}}</div>
                    </div>

                </div>
            </section>
        </div>

        <div class="list-box aui-margin-t-10">
            <div class="row-two-item bgcolor-white" v-for="item in productlist" :key="item.id" @click="gopage(item)">
                <div class="goodimg">  <img onload="fnLoadImage(this)" :data-url="item.cover_pic_url" src="../../image/default.png" /></div>
                <div class="goodtitle">{{item.title}}  </div>
                <div class="aui-info" >
                    <div class="aui-info-item">
                      <span class="sale-price aui-margin-l-5" v-if="item.buy_how==0">￥{{item.pin_price/100}}</span>
                   <span class="sale-price aui-margin-l-5" v-else>￥{{item.directbuy_price/100}}</span>
                     </div>
                  <div class="aui-margin-r-10 sale-info" v-show="item.buy_how==0">已拼{{item.totalsalenum}}件</div>
                </div>
               
            </div>
        </div>


    </div>
    <script>
    </script>

    <script language="javascript">
        var pvm = new Vue({
            el: '#products-box',
            data: {
                page: 1,
                tid: 0,
                totalpage: 1,
                retback: true,
                productlist: [],
                typelogo: [],
                child_first_tid: 0,
                showmore: false,
            },

            methods: {
                opensearch: function(item) {
                  $page.openwin("product_sublist"+item.id,'./sublist.html',{tid:item.id},false);

                },


                gopage: function(item) {
                    $page.openwin('product_productinfo', './productinfo.html', {
                        id: item.id
                    });
                },
                loadinit: function() {

                    $page.get_data('/api/product/getTypeList', 'post', {
                        tid: this.tid,
                        limit: 9
                    }, function(ret) {
                        pvm.typelogo = ret.data;
                        if (ret.data.length > 10) {
                            pvm.showmore = true;
                        }
                        if (ret.data.length > 0) {
                            pvm.child_first_tid = ret.data[0]['id'];
                        }
                    });

                },

                getprdlist: function() {
                    if (pvm.page > pvm.totalpage || !pvm.retback) {
                        return;
                    }
                    pvm.retback = false;
                    $page.get_data('/api/product/getList', 'post', {
                        'page': pvm.page,
                        'tid': pvm.tid
                    }, function(ret) {
                        pvm.totalpage = ret.data.totalpage;
                        pvm.page = pvm.page + 1;
                        pvm.retback = true;
                        ret.data.list.forEach(function(el) {
                            pvm.productlist.push(el);
                        });
                    });
                }
            }
        });


        apiready = function() {
            var pageParam = api.pageParam;
            pvm.tid = pageParam.tid;
            pvm.loadinit();
            $page.init();
            pvm.getprdlist();
            $page.pullreload(function() {
                pvm.getprdlist();
            });
            $page.pullup(function(ret) {
                pvm.getprdlist();
            });
        }
    </script>

</body>


</html>
